package org.ssp.test;

import java.io.IOException;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;

public class SendMsg_webchinese {
	public static void main(String[] args) {
		HttpClient client=new HttpClient();
		PostMethod post=new PostMethod("http://sms.webchinese.cn/web_api/");
		post.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=gbk");
		NameValuePair[] data={new NameValuePair("Uid","Goodsu"),
				               new NameValuePair("Key","d9ee22cec15d941f88c6"),
				               new NameValuePair("smsMob","13428804146"),
				              new NameValuePair("smsText","验证码:121212 【www.overseas-education.co.uk】")
				               };
		post.setRequestBody(data);
		try {
			client.executeMethod(post);
			
		} catch (HttpException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Header[] headers=post.getResponseHeaders();
		int statusCode=post.getStatusCode();
		System.out.println("statusCode"+statusCode);
		for(Header header:headers){
			System.out.println(header.toString());
		}
		String result=null;
		try {
			result=new String(post.getResponseBodyAsString().getBytes("gbk"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(result);
		post.releaseConnection();

		
	}

}
